"""Device auto-selection for CUDA/MPS/CPU (skeleton)."""
from __future__ import annotations


def select_device(policy: str = "auto", prefer_fp16: bool = True):
    try:
        import torch  # type: ignore
    except Exception:
        return "cpu", False

    if policy == "cuda" or (policy == "auto" and torch.cuda.is_available()):
        return "cuda", bool(prefer_fp16)
    mps_ok = getattr(torch.backends, "mps", None) and torch.backends.mps.is_available()
    if policy == "mps" or (policy == "auto" and mps_ok):
        return "mps", False
    return "cpu", False

